class FitnessFunction
	attr_accessor :gain
	attr_accessor :inv
	attr_accessor :rest
	def initialize
		@gain = 25
		@inv = -50
		@rest = -25
	end
	def evaluate(chromosome)
		fitness = 850
		fitness += if chromosome.get_olga.get_book.eql?("Ensayo") then @gain else 0 end
		#Ensayo no esta en ruso
		fitness += if chromosome.get_olga.get_book.eql?("Ensayo") and chromosome.get_olga.get_languaje.eql?("Ruso") then  @rest else 0 end
		fitness += if chromosome.get_silvia.get_book.eql?("Ensayo") and chromosome.get_silvia.get_languaje.eql?("Ruso") then  @rest else 0 end
		fitness += if chromosome.get_juan.get_book.eql?("Ensayo") and chromosome.get_juan.get_languaje.eql?("Ruso") then  @rest else 0 end
		#Olga la tiene la mas larga
		fitness += if chromosome.get_silvia.get_languaje.eql?("Frances") and
				 chromosome.get_olga.is_book_larger_than(chromosome.get_silvia.get_length) then
					 @gain
				 else 0 end
		fitness += if chromosome.get_juan.get_languaje.eql?("Frances") and
				 chromosome.get_olga.is_book_larger_than(chromosome.get_juan.get_length) then
					 @gain
				 else 0 end
		#silvia didn't translate CF nor 290 pages book
		fitness += if chromosome.get_silvia.get_book.eql?("CienciaFiccion") then @rest else 0 end
		fitness += if chromosome.get_silvia.get_pages.eql?(290) then @rest else 0 end
		#juan shouldn't have the shorter book
		fitness += if chromosome.get_juan.get_length.eql?("Breve") then @rest else 0 end
		#ciencia ficcion de 290 paginas		
		fitness += if chromosome.get_silvia.get_book.eql?("CienciaFiccion") and chromosome.get_silvia.get_pages.eql?(290) then @rest else 0 end
		fitness += if chromosome.get_olga.get_book.eql?("CienciaFiccion") and chromosome.get_olga.get_pages.eql?(290) then @rest else 0 end
		fitness += if chromosome.get_juan.get_book.eql?("CienciaFiccion") and chromosome.get_juan.get_pages.eql?(290) then @rest else 0 end
		#ciencia ficcion sin 290 paginas
		fitness += if chromosome.get_silvia.get_book.eql?("CienciaFiccion") and !chromosome.get_silvia.get_pages.eql?(290) then @gain else 0 end
		fitness += if chromosome.get_olga.get_book.eql?("CienciaFiccion") and !chromosome.get_olga.get_pages.eql?(290) then @gain else 0 end
		fitness += if chromosome.get_juan.get_book.eql?("CienciaFiccion") and !chromosome.get_juan.get_pages.eql?(290) then @gain else 0 end
		#juan frances
		fitness += if chromosome.get_juan.get_languaje.eql?("Frances") then @rest else 0 end
		#repeated book
		fitness += if chromosome.get_silvia.get_book.eql?(chromosome.get_juan.get_book) then @inv else 0 end
		fitness += if chromosome.get_olga.get_book.eql?(chromosome.get_silvia.get_book) then @inv else 0 end
		fitness += if chromosome.get_juan.get_book.eql?(chromosome.get_olga.get_book) then @inv else 0 end
		#repeated languaje
		fitness += if chromosome.get_silvia.get_languaje.eql?(chromosome.get_juan.get_languaje) then @inv else 0 end
		fitness += if chromosome.get_olga.get_languaje.eql?(chromosome.get_silvia.get_languaje) then @inv else 0 end
		fitness += if chromosome.get_juan.get_languaje.eql?(chromosome.get_olga.get_languaje) then @inv else 0 end
		#repeated length
		fitness += if chromosome.get_silvia.get_length.eql?(chromosome.get_juan.get_length) then @inv else 0 end
		fitness += if chromosome.get_olga.get_length.eql?(chromosome.get_silvia.get_length) then @inv else 0 end
		fitness += if chromosome.get_juan.get_length.eql?(chromosome.get_olga.get_length) then @inv else 0 end
		#2 books with 290 pages
		fitness += if chromosome.get_silvia.get_pages.eql?(290) and chromosome.get_juan.get_pages.eql?(290) then @inv else 0 end
		fitness += if chromosome.get_silvia.get_pages.eql?(290) and chromosome.get_olga.get_pages.eql?(290) then @inv else 0 end
		fitness += if chromosome.get_olga.get_pages.eql?(290) and chromosome.get_juan.get_pages.eql?(290) then @inv else 0 end
		#no one has 290 pages
		fitness += if !chromosome.get_olga.get_pages.eql?(290) and
			 !chromosome.get_juan.get_pages.eql?(290) and
			 !chromosome.get_olga.get_pages.eql?(290) then
			 @inv
			 else 0 end
	end
end
